
<?php

/**
 * @author christian monzón
 * @copyright 2011
 */

Class CDrawPageReg
{
    //.enviando nuevos cambios.......................
    
    //agregando nueva variable 
    
    public static $instance2;
    public static $instance;
    
 
    
    function __construct()
    {
      
        
    }
    function  DrawHead($action,$name,$method,$NAME){echo "<div id='register-box'>\n";echo "<form action='$action' method='$method' name='$name'>\n";echo "<h2>$NAME</h2>\n";}
    function  DrawFoot(){
        echo "</form>";
        echo "</div>";}
        
    function DrawHideSectionBeg(){
        ?>
       
        <style type="text/css"> 
        div.panel,p.flip
        {margin:12px;padding:5px;text-align:center;background:#bbdaf7;border:solid 2px #a3a3a3;
        }
        div.panel
        {height: auto;display:none;}
        </style>
        <div class="panel">    
        <?php
    }
    
      function DrawHideSectionEnd($name){
        ?>
       
         </div>
        <p class="flip"> <?php echo $name;?></p>
        <?php    
        
    }
    
    
    function  DrawTextBox($items)
    {
        
        ?>
               
               <?php
                    foreach($items as $id => $valor)
                    {
                        echo "<label>".$valor."<input type='text' name='$id' class='general-textarea'>"."</label>";
                        
                    }
               
               ?>
               
           
        <?php
        
    }
    
    function DrawSelectPackages ($table,$campos,$NAME, $id)//especificar los campos que deben de aparecer 
    {
        $query="select " ;
        foreach($campos as $campo => $valor){$query=$query.$valor.",";}
        $query= substr($query,0,strlen($query)-1);
         $query=$query." from ".$table. " where idPack>$id";
        
        $table2=CModelo::getInstance()->getData($query);
        
        
        //var_dump($table2);
        ?>
        
        
        <label><?php echo $NAME;?>
       
        <?php
        foreach($table2 as $row =>$colum)
        {
        $tabla=$colum;$select="";$i=0;
        foreach($tabla as $campo=>$valor)
        {
            //if($i>0){$select=$select."<option value=".$tabla[$campo]."> ";}
            if($i<=0){$select=$select."<option value=".$valor."> ($valor) ";}
            //$select=$select.$tabla[$campo].",";$i=$i+1;
            else{$select=$select.$tabla[$campo].",";}
            $i=$i+1;
        }
        echo $select."</option>\n";
        //echo "<option value=".$tabla['idOfi'].">".$tabla['DirOfi']."</option>\n";    
        }
        ?>
             
        </label>
        
    
    <?php
    }
    
    function DrawSelect($table,$campos,$NAME)//especificar los campos que deben de aparecer 
    {
        $query="select " ;
        foreach($campos as $campo => $valor){$query=$query.$valor.",";}
        $query= substr($query,0,strlen($query)-1);
         $query=$query." from ".$table;
        
        $table2=CModelo::getInstance()->getData($query);
        
        
        //var_dump($table2);
        ?>
        
        
        <label><?php echo $NAME;?>
        <select name="type" class="input_pulldown" id="type">
        <?php
        foreach($table2 as $row =>$colum)
        {
        $tabla=$colum;$select="";$i=0;
        foreach($tabla as $campo=>$valor)
        {
            //if($i>0){$select=$select."<option value=".$tabla[$campo]."> ";}
            if($i<=0){$select=$select."<option value=".$valor."> ($valor) ";}
            //$select=$select.$tabla[$campo].",";$i=$i+1;
            else{$select=$select.$tabla[$campo].",";}
            $i=$i+1;
        }
        echo $select."</option>\n";
        //echo "<option value=".$tabla['idOfi'].">".$tabla['DirOfi']."</option>\n";    
        }
        ?>
        </select>       
        </label>
        
    
    <?php
    }
    
     function getAnyId($maintable,$mainfield,$mainid,$subfield){
        
        $query="select ". $subfield ." from ". $maintable . " where $mainfield= $mainid";
        $table=CModelo::getInstance()->getData($query);
        
        
         foreach($table as $fila=>$columna){
            $tabla1=$columna;
                foreach($tabla1 as $field=>$value)
                {
                $identificador=$value;
            }
         }
         return $identificador;
     
    }
    
    function getDefaultTour($maintable,$mainfield,$mainid,$subfield){
        
        $query="select ". $subfield ." from ". $maintable . " where $mainfield= $mainid AND DefaultTourPack=1";
        $table=CModelo::getInstance()->getData($query);
        
        
         foreach($table as $fila=>$columna){
            $tabla1=$columna;
                foreach($tabla1 as $field=>$value)
                {
                $identificador=$value;
            }
         }
         return $identificador;
     
    }
    
  function DrawButton($nombre,$url){
//      
        echo "<input type=button onClick=\"parent.location='$url'\" value='$nombre'><br/>";
        }


    function DrawRadioButton($items,$name)
    {
      
      echo "<p >";
      
      foreach($items as $id => $valor)
                    {
                        echo "<label>".$id."<input type='radio' class=\"input-radio\" name='$name' value='$valor'>"."</label>\n";
                        
                    }
      
      
      echo "</p>";
      
        
        
    }
    
    function HiddenValue($hidden){
        echo "<input type='hidden' name='idHidden' value='$hidden'>"; 
    }
    
    function DrawSubmmit($nombre){echo "<input class='submit_button' type='submit' name=$nombre value='$nombre'>";}
   
    public static function getInstance()
        {
                //echo "<div id=register-box>";
        if(self::$instance==null)
                  self::$instance=new CDrawPageReg();
        //   echo "</div>";       
                return  self::$instance;
           
    
    }   
    
    
}

?>